﻿Imports Ocean.OceanFramework.BusinessEntity
Imports Ocean.OceanFramework.StringFormatting
Imports Ocean.OceanFramework.Validation

Public Class Contact
    Inherits BusinessEntityBase

#Region " Declarations "

    Private _datBirthday As Nullable(Of Date)
    Private _intId As Integer
    Private _intNumberOfComputers As Integer
    Private _strBlogURL As String = String.Empty
    Private _strComment As String = String.Empty
    Private _strFeedURL As String = String.Empty
    Private _strFirstName As String = String.Empty
    Private _strLastName As String = String.Empty

#End Region

#Region " Properties "

    Public Property Birthday() As Nullable(Of Date)
        Get
            Return _datBirthday
        End Get
        Set(ByVal Value As Nullable(Of Date))
            MyBase.SetPropertyValue("Birthday", _datBirthday, Value)
        End Set
    End Property

    <CharacterCasingFormatting(CharacterCasing.LowerCase)> _
    <StringLengthValidator(100)> _
    <RegularExpressionValidator(RegularExpressionPatternType.URL, RequiredEntry.No)> _
    Public Property BlogURL() As String
        Get
            Return _strBlogURL
        End Get
        Set(ByVal Value As String)
            MyBase.SetPropertyValue("BlogURL", _strBlogURL, Value)
        End Set
    End Property

    <StringLengthValidator(50)> _
    Public Property Comment() As String
        Get
            Return _strComment
        End Get
        Set(ByVal Value As String)
            MyBase.SetPropertyValue("Comment", _strComment, Value)
        End Set
    End Property

    <StringLengthValidator(100)> _
    <RegularExpressionValidator(RegularExpressionPatternType.URL, RequiredEntry.No)> _
    Public Property FeedURL() As String
        Get
            Return _strFeedURL
        End Get
        Set(ByVal Value As String)
            MyBase.SetPropertyValue("FeedURL", _strFeedURL, Value)
        End Set
    End Property

    <StringLengthValidator(1, 30)> _
    <CharacterCasingFormatting(CharacterCasing.ProperName)> _
    Public Property FirstName() As String
        Get
            Return _strFirstName
        End Get
        Set(ByVal Value As String)
            MyBase.SetPropertyValue("FirstName", _strFirstName, Value)
        End Set
    End Property

    <CompareValueValidator(ComparisonType.GreaterThan, 0, RequiredEntry.Yes, PropertyFriendlyName:="Contact Id", RuleSet:="Update|Delete")> _
    Public Property Id() As Integer
        Get
            Return _intId
        End Get
        Set(ByVal Value As Integer)
            MyBase.SetPropertyValue("Id", _intId, Value)
        End Set
    End Property

    <CharacterCasingFormatting(CharacterCasing.ProperName)> _
    <StringLengthValidator(1, 30)> _
    Public Property LastName() As String
        Get
            Return _strLastName
        End Get
        Set(ByVal Value As String)
            MyBase.SetPropertyValue("LastName", _strLastName, Value)
        End Set
    End Property

    <CompareValueValidator(ComparisonType.GreaterThanEqual, 0, RequiredEntry.No)> _
    Public Property NumberOfComputers() As Integer
        Get
            Return _intNumberOfComputers
        End Get
        Set(ByVal Value As Integer)
            MyBase.SetPropertyValue("NumberOfComputers", _intNumberOfComputers, Value)
        End Set
    End Property

#End Region

#Region " Constructor "

    Public Sub New()
    End Sub

#End Region

#Region " Methods "

    Protected Overrides Sub AddSharedBusinessValidationRules(ByVal mgrValidation As Ocean.OceanFramework.Validation.ValidationRulesManager)
        mgrValidation.AddRule(AddressOf ComparisonValidationRules.CompareValueRule, New CompareValueRuleEventArgs(ComparisonType.LessThanEqual, RequiredEntry.No, Date.Now, String.Empty, "Birthday", "Birthday", String.Empty), RuleType.Shared)
    End Sub

#End Region

End Class
